using System;
using System.Windows.Forms;
using System.Collections;

namespace Logger
{
    ///<summary>
    /// New task form
    ///</summary>
    public partial class NewTask : Form
    {
        private ArrayList _taskHistory;//Issue 2: Task history
        /// <summary>
        /// Constructor with task history
        /// </summary>
        /// <param name="taskHistory">Contains the task history</param>
        public NewTask(ArrayList taskHistory)
        {
            _taskHistory = taskHistory;
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            Description = txtDescription.Text;
        }

        ///<summary>
        /// Task description
        ///</summary>
        public string Description;

        private void NewTask_Load(object sender, EventArgs e)
        {
            /* Added to fix issue 8 */
            btnOK.Enabled = false;
            /* Issue 2: Task history */
            txtDescription.Items.Clear();
            foreach(string task in _taskHistory)
            {
                txtDescription.Items.Add(task);
            }
        }

        /* Added to fix Issue 8 */
        private void txtDescription_TextChanged(object sender, EventArgs e)
        {
            btnOK.Enabled = !txtDescription.Text.Trim().Equals("");
        }
    }
}